Here in this article, we will discuss the
<input>
element
type
values.
HTML <input> type attribute
The type attribute of <
input>
element decides which input field should be displayed on the page. It could be a text, date, time, URL, or submit button. The type value we pass in the <input> element the web page will display the corresponding input block.
- type="button"
- type="checkbox"
- type="color"
- type="date"
- type="datetime-local"
- type="email"
- type="file"
- type="hidden"
- type="image"
- type="month"
- type="number"
- type="password"
- type="radio"
- type="range"
- type="reset"
- type="search"
- type="submit"
- type="tel"
- type="text"
- type="time"
- type="url"
- type="week"
Text
To define an input block for the single-line text we can use the
text
value for the
type
attribute.
Example
Preview
Password
The
password
value is used when we want the user to enter a password in the input block.
Example
Preview
Submit
Every
<form>
element contains a submit button, this submits button is used to submit the form data.
Example
Output
The value specified in the
value
attribute will be displayed on the submit button.
Reset
The reset value reset all the filled data. If the input has default values than the data would be reset to their default values.
Example
Preview
Radio
Radio attribute is used to define a number of options from which the user can select only one.
Example
Preview
Checkbox
The checkbox value allow the user to select more than one option.
Example
Preview
Button
The
button
type create a clickable button on the web page.
Example
Preview
Color
The
color
type allows the user to select the colour data. It depends on the browser whether it supports the color value or not.
Example
Preview
Date
The
date
value is used when we want the user to enter a specific date.
Example
Preview
Datetime-local
Datetime-local value defines a date and time input block.
Example
Preview
email
value is used when we want the user to enter the email address. It also provides a form validation if the user entered an invalid email address.
Example
Preview
File
The
file
value is used when we want the user to upload a file from the system.
Example
Preview
Month
The month value defines an input block for month and year data.
Example
Preview
Number
The
number
value specifies an input block which accepts only numbers.
Example
Ouptut
Range
The
range
value create a slider that signifies a range of number. By default, the range is 0 to 100, but it can be altered using
min
and
max
attributes.
Example
Preview
Tel
The
tel
value specifies an input block for phone and telephone number.
Example
Preview
Time
time
value is used for time-related input.
Example
Preview
URL
url
value specifies an input field that only accepts appropriate URL address.
Example
Preview
Week
The
week
value is used to select the week number from a year.
Example
Preview
Summary
- The type attribute defines the input block type for form.
- The text value specifies single-line text input.
- The password value is used for password inputs.
- radio value is used to select one option from multiple choices.
- reset value can reset the form data.
- date, week, and datetime-local values deal with date-related data.